/*
 * @Description: 日志API
 * @Author: chenju
 * @Date: 2022-01-19 10:47:42
 * @LastEditors: qingyang
 * @LastEditTime: 2023-07-03 16:41:57
 */

import { get, getBlob } from '@/utils/http'
import type { BasicPagingListParams, BasicPagingListResult } from '@/apis/basicModel'
import type {
  GetLogListParams,
  GetLogListResult,
  ExportLogParams,
  ILoginLogParams,
  GetLoginLogResult,
  IMailItem,
  IMailParams
} from './model/logListModel'

enum Api {
  // 操作日志列表分页查询
  GET_LOG_LIST = '/upms/log/pageOperation',
  // 日志导出功能
  EXPORT_LOG = '/upms/log/exportOperation',
  // 登录日志
  GET_LOGIN_LIST = '/upms/log/pageLogin',
  // 后台站内信列表
  GET_MAIL_LIST = '/message/message/pageManagerSiteMail'
}

// 操作日志列表分页查询
export const getLogList = (
  params: GetLogListParams & BasicPagingListParams
): Promise<BasicPagingListResult<GetLogListResult>> => get(Api.GET_LOG_LIST, params)

// 日志导出功能
export const exportLog = (params: ExportLogParams): Promise<any> => getBlob(Api.EXPORT_LOG, params)

export const getLoginLog = (
  params: ILoginLogParams & BasicPagingListParams
): Promise<BasicPagingListResult<GetLoginLogResult>> => get(Api.GET_LOGIN_LIST, params)

export const getMailList = (
  params: IMailParams & BasicPagingListParams
): Promise<BasicPagingListResult<IMailItem>> => get(Api.GET_MAIL_LIST, params)
